<?php
	require_once('includes/bootstrap.php');
	
	if (!empty($_SESSION[SESSION_NAME]))
	{
		header("location: " . APPLICATION_URL . 'clients.php');
		exit;
	}
	
	if (!empty($_POST) && !empty($_POST['login']) && !empty($_POST['password']))
	{
		if ($_POST['login'] == ADMIN_LOGIN && $_POST['password'] == ADMIN_PASSWORD)
		{
			$_SESSION[SESSION_NAME] = true;
			header("location: " . APPLICATION_URL . 'clients.php');
			exit;
		}
	}
	
?>

<html>
	<head>
		<?php include_once('includes/head.php'); ?>
	</head>

	<body>

		<h1 style="text-align: center">Connexion</h1>

		<form method="POST">
			
			<table>
				<tr>
					<td>Login</td>
					<td><input type="text" name="login" /></td>
				</tr>
				<tr>
					<td>Mot de passe</td>
					<td><input type="password" name="password" /></td>
				</tr>
				<tr>
					<td colspan="2" style="text-align: right"><button type="submit" id="Submit">Let's go!</button></td>
				</tr>
			</table>
			
		</form>
		
		<script type="text/javascript">
			$("input:text, input:password, textarea").addClass("ui-corner-all");
			
			$('form table').addClass('ui-widget ui-widget-content ui-corner-all');

			$("button").button();
		</script>

	</body>

</html>
